package com.agadmin.controller;

import com.agadmin.manage.UserUpdateManage;
import com.agadmin.request.user.UserUpdateRequest;
import com.agadmin.response.user.UserUpdateResponse;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
public class UpdateUserController {

    @Resource
    UserUpdateManage updateManage;

    @ResponseBody
    @PostMapping("/update")
    private UserUpdateResponse updateUser(@RequestBody @Valid UserUpdateRequest req,
                                          HttpServletRequest httpRequest){
        String userId=httpRequest.getAttribute("userId").toString();
        req.setUserId(userId);
        return updateManage.updateUser(req);
    }

}
